package com.jw.debezuim.utils;

/**
 * @auther wangjianying
 * @date 2023/03/10 13:40
 */
public  class EsIdGenerateUtil {

    public static String generateEsId(String ... unitParts) {
        StringBuilder sb = new StringBuilder();
        for (int j = 0; j < unitParts.length; j++) {
            String unitPart = unitParts[j];
            for (int i = 0; i < unitPart.toCharArray().length; i++) {
                char unitPartC = unitPart.toCharArray()[i];
                String unitPartCHex = Long.toHexString(unitPartC);
                sb.append(unitPartCHex);
                if (i != (unitPart.toCharArray().length - 1) && unitPartCHex.length() != 2) {
                    sb.append("-");
                }
            }
            if (j != (unitParts.length - 1)) {
                sb.append("_");
            }
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        String s = EsIdGenerateUtil.generateEsId("警", "赣123ajf挂");
        char c = '1';
        System.out.println(s);
        System.out.println((int)c);
    }
}
